<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<c:import url="/WEB-INF/jsp/head.jsp" />
<script type="text/javascript" src="<c:url value="/js/md5.js" />"></script>
<script type="text/javascript">

	function submete() {
		document.frm.j_password.value = hex_md5(document.frm.password.value);
		document.frm.password.value = "";
		document.frm.submit();
	}

	$(document).ready(function(){

		$(':input').keypress(function(e) {
			if(e.keyCode == 13) {
				e.preventDefault();
				submete();
			}
		});
		
	});
</script>
</head>
<body>
	<c:import url="/WEB-INF/jsp/cabecalho.jsp" />

	<h1>Login no Sistema</h1>
	<br />
	<form action="j_security_check" method="post" name="frm">
		<table border="0" cellpadding="3" cellspacing="0">
			<tr>
				<td>Usuário:</td>
				<td><input type="text" name="j_username"></td>
			</tr>
			<tr>
				<td>Senha:</td>
				<td><input type="password" name="password"> <input
					type="hidden" name="j_password"></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" value="Acessar" id="btnAcessar"
					onclick="submete()"></td>
			</tr>
		</table>
	</form>
	<c:if test="${not empty param['j_username']}">
		<h3 style="color: red">Login Inválido!</h3>
	</c:if>
	<c:choose>
		<c:when test="${contador == 0}">
			<%
				response.sendRedirect("403.jsp");
			%>
		</c:when>
		<c:when test="${contador > 0}">
			<%
				int contador = ((Integer) session.getAttribute("contador"))
								.intValue();
						contador--;
						session.setAttribute("contador", new Integer(contador));
			%>
		</c:when>
	</c:choose>

	<c:import url="/WEB-INF/jsp/rodape.jsp" />
</body>
</html>